package org.ovirt.jenkins;

import java.io.IOException;

import javax.servlet.ServletException;

import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.kohsuke.stapler.StaplerRequest;

import hudson.Extension;
import hudson.Plugin;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.Descriptor.FormException;

@Extension
public class OVirtPlugin extends Plugin implements Describable<OVirtPlugin> {

	private final static Logger logger = Logger.getLogger(OVirtPlugin.class);
	
	@Override
	public void start() throws Exception {
		logger.info("start");
	}

	@Override
	public void stop() throws Exception {
		logger.info("stop");
	}

	@Override
	public void configure(StaplerRequest req, JSONObject formData)
			throws IOException, ServletException, FormException {
		super.configure(req, formData);
		logger.info("configure");
	}

	@Override
	public void save() throws IOException {
		
		super.save();
	}

	public Descriptor<OVirtPlugin> getDescriptor() {
		return (OVirtPLuginDesciptor) Hudson.getInstance().getDescriptorOrDie(OVirtPlugin.class);
	}

	@Extension
	public static class OVirtPLuginDesciptor extends Descriptor<OVirtPlugin> {

		@Override
		public String getDisplayName() {
			return "oVirt plugin";
		}
		
	}
	
}
